{extend name="base/main" /}
{block name="body"}
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>管理员管理 / 添加管理员</h5>
            </div>
            <div class="ibox-content">
                <form id="f" action="{:url('auth_member/add')}" class="form-horizontal m-t">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">登录名：</label>
                        <div class="col-sm-4">
                            <input name="username" class="form-control" type="text" datatype="s4-16" nullmsg="请输入登录名" errormsg="登录名是4-16位的一个英文字符串">
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 作为登录时的帐号</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">昵称：</label>
                        <div class="col-sm-4">
                            <input name="nickname" class="form-control" type="text" datatype="*2-16" nullmsg="请输入昵称" errormsg="昵称范围在2~16位之间的字符串">
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 登录后显示的名称</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">密码：</label>
                        <div class="col-sm-4">
                            <input name="password" class="form-control" type="password" datatype="s6-16" nullmsg="请输入密码" errormsg="密码范围在6~16位之间,只能是字母和数字">
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 登录使用的密码</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">再次输入密码：</label>
                        <div class="col-sm-4">
                            <input name="password2" class="form-control" type="password" datatype="s6-16" nullmsg="请再次输入密码" recheck="password" errormsg="两次输入的密码不一致">
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 确认两次输入的密码是否相同</span>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">选择角色：</label>
                        <div class="col-sm-4">
                            <select name="role_id" class="form-control" onchange="select_post(this);" datatype="*" nullmsg="请选择角色" errormsg="请选择角色">
                                <option value="">请选择角色</option>
                                {volist name="authGroup" id="vo"}
                                    <option value="{$vo.id}">{$vo.title}</option>
                                {/volist}
                            </select>
                            <span class="help-block m-b-none Validform_checktip" ><i class="fa fa-info-circle"></i> 选择角色</span>
                        </div>
                    </div>
                   

                    <div class="hr-line-dashed"></div>
                    <div class="form-group">
                        <div class="col-sm-4 col-sm-offset-3">
                            <input type="hidden" name="user_type" value="1">
                            <button class="btn btn-primary" type="submit">提交</button>
                            <button class="btn btn-default historygo" type="button">返回</button>
                        </div>
                    </div>
                </form>
            </div>
                
        </div>
    </div>

    <script type="text/javascript">
        function select_post(th) {
            var roleId = $(th).val();
            $.ajax({
                url :"{:url('AuthMember/rolePost')}",
                data:{role_id:roleId},
                type:'post',
                dataType:'json',
                success :function(ret) {
                    var html = '<option value="">请选择岗位</option>';
                    if( ret.code == 1 ) {
                        $.each(ret.data, function(key, val) {
                            html += '<option value="'+val.id+'">'+val.name+'</option>';
                        });
                    }
                    $('#post_id').html( html );
                    $('#post_id').removeClass('Validform_error');
                    $('#post_id').parent().find('.Validform_checktip').removeClass('Validform_wrong').removeClass('Validform_right').html('<i class="fa fa-info-circle"> 选择岗位</i>');
                }
            });
        }
    </script>
{/block}